<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\Storage;

class Admin extends Authenticatable
{
    protected $table = 'admin_users';
    protected $guarded = [];
    //public $timestamps = false;

    // 追加未登录天数属性
    protected $appends = ['avatars'];

    /**
     * @param $value
     */
    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = bcrypt($value);
    }

    // 处理没登陆天数
    public function getAvatarsAttribute()
    {
        $value = $this->attributes['avatar'];
        if (config('filesystems.default') == "qiniu") {
            $disk = Storage::disk();
            $value = $disk->downloadUrl($value);
        }
        return $value;
    }

}
